﻿using System;
using System.Linq;
using System.Web.Mvc;
using AutoMapper;
using App.Interface;
using Domain.Entidades;
using SiteCredivale.ViewModels;
using System.Collections.Generic;
using System.Web.Script.Serialization;


namespace SiteCredivale.Controllers
{
    public class HomeController : Controller
    {


        private readonly IVW_menuAppService _menuapp;
        private readonly IVW_noticiasAppService _noticiaspp;
        private readonly IUsuarioAppService _usuarioapp;

        public HomeController(IVW_menuAppService menuapp,IVW_noticiasAppService noticiasapp,IUsuarioAppService usuarioapp)
        {

            try
            {
                _menuapp = menuapp;
                _noticiaspp = noticiasapp;
                ViewBag.menu = _menuapp.GetAll();
                ViewBag.noticias = _noticiaspp.GetAll().Take(10).OrderByDescending(x => x.not_codigo).ToList();
                _usuarioapp = usuarioapp;
            }
            catch (Exception ex)
            {

                throw;
            }

           

        }

        public ActionResult Index()
        {
            try
            {


                return View();


            }
            catch (Exception ex)
            {

                TempData["msg_err"] = ex.Message;

                return RedirectToAction("erro", "Home");
            }


        }

        public ActionResult erro_squid()
        {
            try
            {

            

                return View("erro_squid");

            }
            catch (Exception ex)
            {

                TempData["msg_err"] = ex.Message;
                return RedirectToAction("erro", "Home");
            }


        }

        public ActionResult erro()
        {

  
            return View();
        }

        public ActionResult erro_customizado()
        {

          
            return View();
        }

        public ActionResult NotFound()
        {

            return View();
        }

     




    }
}
